package org.liukai.ems.dao;

import org.liukai.ems.entity.po.User;
import org.mybatis.spring.support.SqlSessionDaoSupport;
import org.springframework.stereotype.Repository;

import java.util.List;


@Repository
public class UserDao extends SqlSessionDaoSupport {
    public User queryUserByUserName(String userName) {
        return getSqlSession().selectOne("user.queryUserByUserName", userName);
    }

    public List<User> queryAllUser() {
        return getSqlSession().selectList("user.queryAllUser");
    }



    public void addUser(User user) {
        getSqlSession().insert("user.addUser" ,user);
    }

    public User queryUserByUserId(String userId) {
        return getSqlSession().selectOne("user.queryUserByUserId", Integer.parseInt(userId));
    }

    public void deleteUser(String userId) {
        getSqlSession().delete("user.deleteUser", Integer.parseInt(userId));
    }

    public void updateUser(User user) {
        getSqlSession().update("user.updateUser", user);
    }
}
